import type { MultipleConditionSearchSchema } from '@/components/multiple-condition-search'

export function useConfig() {
  const tableColumns = computed(() =>
    buildColumns([
      {
        dataIndex: 'type',
        title: '操作类型',
        width: 140,
        render: ({ record }) => {
          return getOptionLabel(record.type, adminOptTypeOptions, '-')
        },
      },
      {
        dataIndex: 'module_name',
        title: '操作模块',
        maxWidth: 160,
      },
      {
        dataIndex: 'content',
        title: '操作内容',
        minWidth: 240,
      },
      {
        dataIndex: 'username',
        title: '操作账号',
        maxWidth: 160,
      },
      {
        dataIndex: 'ip',
        title: 'IP地址',
        maxWidth: 160,
        format: 'copy',
      },
      {
        dataIndex: 'ip_region',
        title: 'IP所在地',
        maxWidth: 180,
      },
      {
        dataIndex: 'operated_at',
        title: '操作时间',
        maxWidth: 180,
        sortable: sortableSettings,
        format: 'date-time',
      },
      {
        dataIndex: 'trace_id',
        title: 'TraceID',
        minWidth: 180,
        format: 'copy',
      },
    ]),
  )

  const filterSchemes: MultipleConditionSearchSchema = {
    placeholder: '默认按照操作内容搜索',

    widgets: [
      {
        type: 'input',
        field: 'content',
        label: '操作内容',
        placeholder: '请输入操作内容',
      },
      {
        type: 'input',
        field: 'module_name',
        label: '操作模块',
        placeholder: '请输入操作模块',
      },
      {
        type: 'input',
        field: 'username',
        label: '操作账号',
        placeholder: '请输入操作账号',
      },
    ],
  }

  return { tableColumns, filterSchemes }
}
